package GCJ2009.Round1C;

import java.io.*;
import java.util.*;

public class Center_of_Mass {

    BufferedReader fin;
    PrintWriter fout;

    void openFiles() throws IOException {
        fin = new BufferedReader(new FileReader("B-large.in"));
        fout = new PrintWriter(new BufferedWriter(new FileWriter("B-large.out")));
    }

    void closeFiles() throws IOException {
        fin.close();
        fout.close();
    }

    int N;
    double sx, sy, sz, svx, svy, svz;
    
    void input() throws IOException {
        sx = 0; sy = 0; sz = 0; svx = 0; svy = 0; svz = 0;
        N = Integer.parseInt(fin.readLine());
        for (int i = 0; i < N; i++)
        {
            String s = fin.readLine();
            StringTokenizer ss = new StringTokenizer(s);
            sx += Integer.parseInt(ss.nextToken());
            sy += Integer.parseInt(ss.nextToken());
            sz += Integer.parseInt(ss.nextToken());
            svx += Integer.parseInt(ss.nextToken());
            svy += Integer.parseInt(ss.nextToken());
            svz += Integer.parseInt(ss.nextToken());
        }

        sx /= N;
        sy /= N;
        sz /= N;
        svx /= N;
        svy /= N;
        svz /= N;
    }

    double distance(double x1, double y1, double z1, double x2, double y2, double z2)
    {
        return Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));
    }

    void process() {
        double sum = sx*svx + sy*svy + sz*svz;

        double time = - sum / (svx*svx + svy*svy + svz*svz);
        
        if (Double.isNaN(time) || (time < 0))
            fout.println(distance(0, 0, 0, sx, sy, sz) + " " + 0);
        else
            fout.println(distance(0, 0, 0, sx + time*svx, sy + time*svy, sz + time*svz) + " " + time);
    }

    void output() {
    }

    void takeTest() throws IOException
    {
        int nTest = Integer.parseInt(fin.readLine());
        for (int test = 1; test <= nTest; test++)
        {
            input();
            fout.print("Case #" + test + ": ");
            process();
            output();
        }
    }

    public static void main(String[] args) throws IOException {
        Center_of_Mass myProgram = new Center_of_Mass();

        myProgram.openFiles();
        myProgram.takeTest();
        myProgram.closeFiles();
    }
}